<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>订单页</title>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/order.css"/>
		<script src="./Public/Home/js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="./Public/Home/js/area.js"></script>
	</head>
	<body>
		{{include file="../Common/header"}}
		<!--主要部分-->
		<div id="main">
			<div class="main_1200">
				<p class="buy_tips">填写并核对订单信息</p>
				<h2 class="send_way">配送方式</h2>
				<div class="wlps">
					<div class="wlps_box">
						<p class="title">物流配送</p>
						<p class="info">商品将由迪信通以快递的方式发送给您</p>
						<i class="icon"></i>
					</div>
				</div>
				<h2 class="get_address">收货地址</h2>
				<div class="address">
					{{foreach from="$addressData" value="$u"}}
					<div class="address_box" chooseRid="{{$u['rid']}}" state="{{$u['restate']}}" {{if value="$u['restate'] eq 1"}}class="address_box1"{{endif}}>
						<p class="name">{{$u['rename']}}</p>
						<p class="tel">{{$u['rephone']}}</p>
						<p class="info">{{$u['province']}} &nbsp; {{$u['city']}} &nbsp; {{$u['xian']}}  &nbsp;{{$u['deaddress']}}</p>
						<p class="operate">
							<a href="javascript:if(confirm('确定删除吗？'))  location.href='{{U('delAddress',array('rid'=>$u['rid']))}}';" class="btn del_ad">删除</a>
						</p>
						<i class="icon"></i>
					</div>
					{{endforeach}}
<!--					默认选中地址-->
					<script>
						window.onload=function(){
							$('.address_box').each(function(){
									if($(this).attr('state')==1){
										$(this).addClass('address_box1').siblings().removeClass('address_box1');
									}
								})
						}
					</script>
<!--					点击选中地址-->
					<script>
						$(function(){
							$('.address_box').click(function() {
								$(this).addClass('address_box1').siblings().removeClass('address_box1');
								var rid=$(this).attr('chooseRid');
//									alert(rid);
								$.ajax({
									type:"post",
									url:"{{U('Order/chooseAddress')}}",
									data:{r:rid},
								})
							})
						})
					</script>
					<div class="address_addbox">
						<p class="icon">+</p>
						<p class="name">新增收货地址</p>
					</div>
					<!--添加地址弹出框-->
					<script type="text/javascript">					
						$(function(){
							$(".address_addbox").click(function(){
								$("#zhezhao").fadeIn(200);
								$(".close").click(function(){
									$("#zhezhao").fadeOut(200);
								})
							});
						})
					</script>
				</div>
				<h2 class="goods_list">商品清单</h2>
				<div class="buy_listbox">
					{{if value="isset($allData)"}}
					{{foreach from="$allData['goods']" $key="$k" value="$u"}}
					<div class="buy_item2">
						<div class="item2_top">
							<div class="item2_top1">
								<a href="{{U('Detail/index',['coid'=>$u['id']])}}" class="good_img_box">
									<img src="{{$u['commodimg']}}" alt="" />
								</a>																							
								<div class="goods_infobox1">
									<p class="goods_titletext">{{$u['name']}}</p>
									<p class="cgoods_info1">
										{{foreach from="$u['options']" value="$v"}}
										<span>{{$v}}</span>
										{{endforeach}}
									</p>
									<p class="cgoods_price">￥<span>{{$u['price']}}</span></p>
								</div>
							</div>
							<div class="item2_top2">
								<p class="title">数量：</p>
								<p class="info"><span>{{$u['num']}}</span>台</p>
							</div>
							<div class="item2_top3">
								<p class="address">发货地：<span>北京市</span></p> 
								<p class="true_buy">小计：￥<span>{{$u['total']}}</span></p>
							</div>
						</div>
					</div>
					{{endforeach}}
					{{endif}}
				</div>
				<h2 class="remark_title">添加订单备注</h2>
				<textarea name="ordernote" rows="5" cols="" placeholder="限100个字" id="ordernote" ></textarea>
				<div class="sub_info">
					<div class="left_mess">
						<p>发货时间：当天16：00前下单 18：00后发货，16：00后下单第二天上午发货</p>
						<p>温馨提示：因发货地不同，具体到货时间是发货地远近而定。 我们会在您提交订单后立即处理。</p>
						<p>到货时间：2-3天（新疆、西藏、港澳台等地区除外）</p>
					</div>
					<div class="right_mess">
						<p class="rows">共<span id="allconum">{{if value="isset($allNum)"}}{{$allNum}}{{else}}0{{endif}}</span>件商品，应付：<i>￥</i><span>{{if value="isset($allpri)"}}{{$allpri}}{{else}}0{{endif}}</span></p>
						<p class="rows">运费：<i>￥</i><span>0.00</span></p>
						<p class="rows">已节省：	<i>￥</i><span>{{$shengsum}}</span></p>
						<p class="rows">实付：<i>￥</i><span class="num" id="orderpri">{{if value="isset($allpri)"}}{{$allpri}}{{else}}0{{endif}}</span></p>
						<input type="submit" class="submit_btn" value="提交订单">
					</div>
					<script>
						$(function(){
							$('.submit_btn').click(function(){
								var orderpri=$('#orderpri').html();
								var ordernote=$('#ordernote').val();
								var shop_receipt_rid=$('.address_box1').attr('chooseRid');
								if(shop_receipt_rid){
								$.ajax({
									type:"post",
									url:"{{U('orderd')}}",
									data:{orderpri:orderpri,ordernote:ordernote,shop_receipt_rid:shop_receipt_rid},
									success(){
//										alert(1);
										location.href=("{{U('orderpay')}}");
									}
								})
							}else{
								alert("请先添加地址或者选择一个已有的地址哦");
							}
							})
						})
					</script>
				</div>
			</div>
		</div>
		<!--收货地址框开始-->
		<div id="zhezhao">
			<div class="address_form">
				<form action="{{U('addAddress')}}" method="post" id="addform">
					<h3 class="title">添加地址</h3>
					<div class="form_group">
						<label for="" class="label">							
							<span class="must">*</span>
							所在区域：
						</label>
						<script type="text/javascript">
							$(function(){
								//初始化方法
								area.init('a');
								//修改的时候默认被选中效果
								// area.selected('黑龙江','哈尔滨','道里区');
							})
						</script>
						<div class="addselect">
							<select name="province" id="a1">

							</select>
							<select name="city" id="a2">

							</select>
							<select name="xian" id="a3">

							</select>
						</div>
					</div>
					<div class="form_group">
						<label for="" class="label">							
							<span class="must">*</span>
							详细地址：
						</label>
						<input type="text" name="deaddress" id="" value="" />
					</div>
					<div class="form_group">
						<label for="" class="label">							
							<span class="must">*</span>
							收货人：
						</label>
						<input type="text" name="rename" id="" value="" />
					</div>
					<div class="form_group">
						<label for="" class="label">							
							<span class="must">*</span>
							手机号码：
						</label>
						<input type="text" name="rephone" id="" value="" />
					</div>
					<div class="form_group">
						<label for="" class="label">
							<span class="must"></span>
						</label>
					</div>
					<p class="save_btn"><input type="submit" value="保存地址"></p>
					<a href="javascript:;" class="close">X</a>
				</form>
			</div>
		</div>
		<!--收货地址框结束-->
		<!--底部区域-->
		{{include file="../Common/footer"}}
		<!--底部区域-->
	</body>
</html>
